//x 加上x个位数的和=y；那么x就是y的生成元

#include<iostream>
# define maxn 10005
int ans[maxn];
using namespace std;

int main( ) {
    int times, n;
    memset(ans, 0, sizeof(ans));
    for (int i = 0; i != maxn; i++) {
        int x = i, y = i;
        while (x > 0) {
            y += x % 10;
            x /= 10;
        }
        if (ans[y] == 0 || i < ans[y]) {
            ans[y] = i;
        }
    }
    cout << "请输入判断次数" << endl;
    cin >> times;
    while (times --) {
        cin >> n;
        cout << n << "的最小生成元是" << ans[n] << endl;
    }
    return 0;
}
